<%
    var headContent = {
%>
<link rel="stylesheet" href="${base}/template/common/css/uploadify/uploadify.css"/>
<style>
/*uploadify上传 begin*/
    .uploadify-queue-item .cancel a {
      background: url('${base}/template/common/images/uploadify-cancel.png') 0 0 no-repeat;
      float: right;
      height: 16px;
      text-indent: -9999px;
      width: 16px;
    }
    .uploadify-button {
      background: url('${base}/template/common/images/uploadify_btn_focus.png');
      border-radius: 5px;
      border: none;
    }
    .uploadify:hover .uploadify-button {
      background: url('${base}/template/common/images/uploadify_btn_hover.png');
      border-radius: 5px;
      border: none;
    }
/*模态窗口 end*/
</style>
<%
};
%>
<%layout("/common/_layout.html",{head:headContent}){ %>
<div>
    <% include("/admin/waiting_hint.tpl"){}%></div>
<div class="am-cf am-padding">
    <div class="am-fl am-cf"> <strong class="am-text-primary am-text-lg">系统管理</strong>
        /
        <small>APP版本管理</small>
    </div>
</div>
<form id="list-form" class="am-form" action="${base}/deviceversion/list" method="post">
    <input type="hidden" id="keywords" name="keywords" value='${keywords!""}' />
    <table class="am-table am-table-bordered am-table-radius table-main">
        <tbody>
            <tr>
                <th class="am-text-middle">版本类型</th>
                <td>
                    <div class="am-u-sm-10">
                        <select data-am-selected="{btnSize:'sm'}" name="app_type" id="app_type">
                            <option value="0" <%if(app_type=="0"){%>
                                selected
                                <%}%>>所有版本</option>
                            <option value="1" <%if(app_type=="1"){%>
                                selected
                                <%}%>>IOS苹果系统</option>
                            <option value="2" <%if(app_type=="2"){%>
                                selected
                                <%}%>>Android系统</option>
                        </select>
                    </div>
                </td>
                <th class="am-text-middle">发布日期</th>
                <td>
                    <div class="am-u-sm-10">
                        <div class="am-form am-form-inline">
                            <div class="am-form-group am-form-icon"> <i class="am-icon-calendar"></i>
                                <input type="text" class="am-form-field am-input-sm" placeholder="开始时间" data-am-datepicker id="start_date" value="${start_date!}" readonly></div>
                            <div class="am-form-group">至</div>
                            <div class="am-form-group am-form-icon"> <i class="am-icon-calendar"></i>
                                <input type="text" class="am-form-field am-input-sm" placeholder="结束时间" data-am-datepicker id="end_date" value="${end_date!}" readonly></div>
                        </div>
                    </div>
                </td>
                <td >
                    <div align='right'>
                        <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" id="submit-btn">搜索</button>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</form>
<div class="am-u-sm-12 am-u-md-6" style="padding:0px 1.6rem 1.6rem 1rem;margin:0px;">
    <div class="am-btn-toolbar">
        <div class="am-btn-group am-btn-group-xs" >
            <%if(so.hasPermission("ROLE_CREATE")) {%>
            <button type="button" class="am-btn am-btn-default" onclick="location.href='${base}/deviceversion/create'">
                <span class="am-icon-plus"></span>
                新增
            </button>
            <%}%>
            <%if(so.hasPermission("ROLE_DELETE")) {%>
            <button type="button" id="deleteButton" disabled="disabled" class="am-btn am-btn-default" onclick="deleteAll('${base}/deviceversion/delete')">
                <span class="am-icon-trash-o"></span>
                删除
            </button>
            <%}%></div>
    </div>
</div>
<div class="am-g">
    <div class="am-u-sm-12">
        <table class="am-table am-table-striped am-table-hover table-main">
            <thead>
                <tr class="am-text-nowrap">
                    <th class="table-check">
                        <input type="checkbox" id="allCheck"></th>
                    <th class="table-title">设备类型</th>
                    <th class="table-title">应用名称</th>
                    <th class="table-title">版本号</th>
                    <th class="table-title">APP文件名称</th>
                    <th class="table-title">APP大小</th>
                    <th calss="table-title">是否发布</th>
                    <th calss="table-title">强制升级</th>
                    <th class="table-title">操作</th>
                </tr>
            </thead>
            <tbody >
                <%for(list in pager.list){%>
                <tr>
                    <td>
                        <input type="checkbox"  name="ids" value="${list.id}"/>
                    </td>
                    <td>${list.type}</td>
                    <td>${list.appName}</td>
                    <td>${list.version}</td>
                    <td>${list.fileName}</td>
                    <td>${list.fileSize}</td>
                    <td><%if(list.ispublic==1){%>是<%}else{%>否<%}%></td>
                    <td><%if(list.isForceUpdate==1){%>是<%}else{%>否<%}%></td>
                    <td>
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <%if(so.hasPermission("ROLE_EDIT")) {%>
                                <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="location.href='${base}/deviceversion/edit?id=${list.id}'">
                                    <span class="am-icon-pencil-square-o"></span>
                                    编辑
                                </button>
                                <%}%></div>
                        </div>
                    </td>
                </tr>
                <%}%></tbody>
        </table>
        <div class="am-cf">
            <!-- 分页 -->
            <%if (pager.list.~size >
            0){%>
            <div class="am-fr" <%if(pager.list.~size ==1){%>
                style="height:500px"
                <%}%>
                >
                <% include("/admin/common_pager.tpl"){}%></div>
            <%}else{%>
            <div class="am-kai" style="height:500px">
                <h3>没有找到任何记录!</h3>
            </div>
            <%}%></div>
    </div>
</div>

<script type="text/javascript">
    var urlBase = "${base}";

    $(function(){
        var keywordsObj = {};
        $("#submit-btn").on("click",function(){
            if($("#app_type").val())
                keywordsObj.app_type = $("#app_type").val();
            if($("#start_date").val())
                keywordsObj.start_date = $("#start_date").val();
            if($("#end_date").val())
                keywordsObj.end_date = $("#end_date").val();

            var keywords = "";
            if(!$.isEmptyObject(keywordsObj)){
              keywords = JSON.stringify(keywordsObj);
            }
            console.log("keywords = "+ keywords);
            $("#keywords").val(keywords);
            showWaitingHint("正在查询，请稍候...");
            $("#list-form").submit();
        });
    });

    function showDialog(msgTitle, message, msgType, msgTimer){
        sendMessage({
            title : msgTitle,
            text : message,
            type : msgType,
            timer : msgTimer,
            confirmButtonText : false
        });
    }

    function isInt(data) {
        var result = false;
        if (typeof data != 'undefined') {
            // 正则表达式 匹配 判断是负数 0 正数
            //var regexp = /^\d*$/;
            var regexp =  /^[+-]?\d*$/;
            if (regexp.test(data)) {
                result = true;
            } else {
                result = false;
            }
        }
        return result;
    }
    </script>
<%}%>